//
// Created by wenbo on 24-7-26.
//
#include "com.h"
#include "usart.h"


VSA2PC_msg stateMsg;
VSA_state vsa_state;

void pack_n_go(VSA2PC_msg * stateMsg, VSA_state * vsa_state)
{
    stateMsg->HEAD[0] = 0xFF;
    stateMsg->HEAD[1] = 0xFE;

    stateMsg->state.angle_sensor = vsa_state->angle_sensor;
    stateMsg->state.motor_pos = vsa_state->motor_pos;
    stateMsg->state.motor_speed = vsa_state->motor_speed;
    stateMsg->state.mrc1_state = vsa_state->mrc1_state;
    stateMsg->state.mrc2_state = vsa_state->mrc2_state;

    stateMsg->crc = 0xEE;

    HAL_UART_Transmit_DMA(&huart2, (uint8_t *)stateMsg, sizeof(* stateMsg));
}